<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
学院:<select onchange="showMajor()"></select>
专业：<select></select>
所选结果：<span id="jg"></span>
<script>
    var obj;

    var xhr = new XMLHttpRequest();

    xhr.open("GET", "school.json", true);

    xhr.send();

    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            var data = xhr.responseText;
            obj = JSON.parse(data);

            var school = document.querySelector("select")
            for (var i = 0; i < obj.schools.length; i++) {
                school.options[i] = new Option(obj.schools[i].name);
            }
            showMajor();
        }
    }

    function showMajor() {
        var index = document.querySelectorAll("select")[0].selectedIndex;
        var school = obj.schools[index];

        var major = document.querySelectorAll("select")[1];
        major.length = 0;
        var i;
        for (i = 0; i < school.majors.length; i++) {
            major.options[i] = new Option(school.majors[i].major);
        }
    }
</script>
</body>
</html>